package com.wausinterest;

import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.wausinterest.R;
import com.wausinterest.util.Model;

public class InteractiveArrayAdapter extends ArrayAdapter<Model> {
	private final List<Model> list;
	private final LayoutInflater mInflater;

	public InteractiveArrayAdapter(Context context, List<Model> list) {
		super(context, R.layout.item, list);
		this.list = list;
		this.mInflater = LayoutInflater.from(context);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = null;
		if (convertView == null) {
			view = mInflater.inflate(R.layout.item, parent, false);
		} else {
			view = convertView;
		}
		ImageView ivImage = (ImageView) view.findViewById(R.id.ivImage);
		TextView tvTitle = (TextView) view.findViewById(R.id.tvTitle);
		TextView ivContent = (TextView) view.findViewById(R.id.tvContent);
		TextView ivUrl = (TextView) view.findViewById(R.id.tvUrlContext);
		// ivImage.setImageResource(resId)
		tvTitle.setText(list.get(position).getStrTitle());
		ivContent.setText(list.get(position).getStrContent());
		ivUrl.setText(list.get(position).getStrUrlContext());
		return view;
	}
}